<?php 
include ("../conectar.php"); 

$fechahoy=date("Y-m-d");

$codigo_plantilla=$_GET['pe'];
if(empty($codigo_plantilla))
{$codigo_plantilla=$_POST['codPlant'];}

$des_plant=$_GET['desc'];
if(empty($des_plant))
{$des_plant=$_POST['descPlant'];}

$tipoLiq=$_GET['tipoLiq'];
if(empty($tipoLiq))
{$tipoLiq=$_POST['tipoLiq'];}

//echo ("Cod:".$codigo_plantilla." Desc: ".$des_plant." Tipo: ".$tipoLiq);
$sel_tipo="SELECT titulo FROM tipo_liquidacion WHERE abreviacion like '$tipoLiq'";
$rs_tipo=mysql_query($sel_tipo);
$titulo=mysql_result($rs_tipo,0,"titulo");

//seleccionar datos de la moneda maestra

?>
<html>
	<head>
		<title>Principal</title>
		<link href="../estilos/estilos.css" type="text/css" rel="stylesheet">
		<link href="../calendario/calendar-blue.css" rel="stylesheet" type="text/css">
		<script type="text/JavaScript" language="javascript" src="../calendario/calendar.js"></script>
		<script type="text/JavaScript" language="javascript" src="../calendario/lang/calendar-sp.js"></script>
		<script type="text/JavaScript" language="javascript" src="../calendario/calendar-setup.js"></script>
		<script type="text/javascript" language="javascript" src="../funciones/tabla.js"></script>
		<script type="text/javascript" language="javascript" src="../funciones/calculos.js"></script>				
		<script language="javascript">
		var cursor;
		if (document.all) {
		// Está utilizando EXPLORER
		cursor='hand';
		} else {
		// Está utilizando MOZILLA/NETSCAPE
		cursor='pointer';
		}
		
		var miPopup
		function abreVentana(obj){
			var tab=obj.parentNode.parentNode.parentNode.parentNode.id;//id de la tabla			
			//iniciarTabla(tab);	
			//inicia2();
			miPopup = window.open("ver_clientes2.php","miwin","width=700,height=380,scrollbars=yes");
			miPopup.focus();
		}
		
		function ventanaArticulos(){
			var codigo=document.getElementById("codcliente").value;
			if (codigo=="") {
				alert ("Debe introducir el codigo del cliente");
			} else {
				miPopup = window.open("ver_articulos.php","miwin","width=700,height=500,scrollbars=yes");
				miPopup.focus();
			}
		}

		function ventanaConceptos(celda){
			
			tab=celda.parentNode.parentNode.parentNode;

			miPopup = window.open("ver_conceptos.php?fila="+celda.parentNode.rowIndex+"&columna="+celda.cellIndex+"&tab="+tab.id,"miwin","width=700,height=600,scrollbars=yes");
			miPopup.focus();
		}
		
		function ventanaConceptosDato(celda){
			
			tab=celda.parentNode.parentNode.parentNode;

			miPopup = window.open("ver_conceptosDatos.php?fila="+celda.parentNode.rowIndex+"&columna="+celda.cellIndex+"&tab="+tab.id,"miwin","width=700,height=600,scrollbars=no");
			miPopup.focus();
		}

		function validarcliente(){
			//var codigo=document.getElementById("codcliente").value;
			var codigo=document.getElementById("nombre").value;
			miPopup = window.open("comprobarcliente.php?codcliente="+codigo,"frame_datos","width=700,height=80,scrollbars=yes");
		}	
		
		function cancelar() {
			var tipo=document.getElementById('liqTipo').value;
			location.href="index.php?tipo="+tipo;
		}
		
		function limpiarcaja() {
			document.getElementById("nombre").value="";
			document.getElementById("nif").value="";
		}


		function verPlantilla(){						
			miPopup = window.open("ventana_plantilla.php","miwin","width=700,height=380,scrollbars=yes");
			miPopup.focus();
		}			

		function format(input)
		{
//			var num = input.value.replace(/\./g,”);
			var num = input.value;
			document.getElementById('prueba').value=num;
/*
			if(!isNaN(num)){
				num = num.toString().split(”).reverse().join(”).replace(/(?=\d*\.?)(\d{3})/g,’$1.’);
				num = num.split(”).reverse().join(”).replace(/^[\.]/,”);
				input.value = num;
			}
			else
			{ alert("Solo se permiten numeros");				
			}
*/
		}

		function actualizar_importe()
			{
				var precio=document.getElementById("precio").value;
				var cantidad=document.getElementById("cantidad").value;
				var descuento=document.getElementById("descuento").value;
				descuento=descuento/100;
				total=precio*cantidad;
				descuento=total*descuento;
				total=total-descuento;
				var original=parseFloat(total);
				var result=Math.round(original*100)/100 ;
				document.getElementById("importe").value=result;
			}
			
		function validar_cabecera()
		{
			var mensaje="";
			if (document.getElementById("nombre").value=="") 
				mensaje+="Ningun Cliente asignado!\n";

			if (document.getElementById("total").value=="" || document.getElementById("total").value==0) 
				mensaje+="El total no puede estar vacio o ser cero!\n";
				
			if (mensaje!="") {
				alert("Atencion, se han detectado las siguientes incorrecciones:\n\n"+mensaje);
			} 
			else 
			{					
				grabar_liq();

				//copiar otros datos de los otros formularios
				document.getElementById('cliente_liq').value=document.getElementById('nombre').value;
				document.getElementById('importe_total_liq').value=document.getElementById('total').value;
				
				document.getElementById("formulario").submit();
			}
				
		}	
		
		function validar() 
			{
				var mensaje="";
				var entero=0;
				var enteroo=0;
		
				if (document.getElementById("referencia").value=="") mensaje="  - Referencia\n";
				if (document.getElementById("descripcion").value=="") mensaje+="  - Descripcion\n";
				if (document.getElementById("precio").value=="") { 
							mensaje+="  - Falta el precio\n"; 
						} else {
							if (isNaN(document.getElementById("precio").value)==true) {
								mensaje+="  - El precio debe ser numerico\n";
							}
						}
				if (document.getElementById("cantidad").value=="") 
						{ 
						mensaje+="  - Falta la cantidad\n";
						} else {
							enteroo=parseInt(document.getElementById("cantidad").value);
							if (isNaN(enteroo)==true) {
								mensaje+="  - La cantidad debe ser numerica\n";
							} else {
									document.getElementById("cantidad").value=enteroo;
								}
						}
				if (document.getElementById("descuento").value=="") 
						{ 
						document.getElementById("descuento").value=0 
						} else {
							entero=parseInt(document.getElementById("descuento").value);
							if (isNaN(entero)==true) {
								mensaje+="  - El descuento debe ser numerico\n";
							} else {
								document.getElementById("descuento").value=entero;
							}
						} 
				if (document.getElementById("importe").value=="") mensaje+="  - Falta el importe\n";
				
				if (mensaje!="") {
					alert("Atencion, se han detectado las siguientes incorrecciones:\n\n"+mensaje);
				} else {
					document.getElementById("baseimponible").value=parseFloat(document.getElementById("baseimponible").value) + parseFloat(document.getElementById("importe").value);	
					cambio_iva();
					document.getElementById("formulario_lineas").submit();
					document.getElementById("referencia").value="";
					document.getElementById("descripcion").value="";
					document.getElementById("precio").value="";
					document.getElementById("cantidad").value=1;
					document.getElementById("importe").value="";
					document.getElementById("descuento").value=0;						
				}
			}

		function validar2() 
		{
			var mensaje="";

			if (document.getElementById("descripcion").value=="") mensaje+="  - Descripcion\n";
			if (document.getElementById("importe").value=="") mensaje+="  - Falta el importe\n";
			
			if (mensaje!="") {
				alert("Atencion, se han detectado las siguientes incorrecciones:\n\n"+mensaje);
			} else {
				document.getElementById("formulario_lineas").submit();
				document.getElementById("descripcion").value="";
				document.getElementById("importe").value="";					
			}
		}
			
		function cambio_iva() {
			var original=parseFloat(document.getElementById("baseimponible").value);
			var result=Math.round(original*100)/100 ;
			document.getElementById("baseimponible").value=result;
	
			document.getElementById("baseimpuestos").value=parseFloat(result * parseFloat(document.getElementById("iva").value / 100));
			var original1=parseFloat(document.getElementById("baseimpuestos").value);
			var result1=Math.round(original1*100)/100 ;
			document.getElementById("baseimpuestos").value=result1;
			var original2=parseFloat(result + result1);
			var result2=Math.round(original2*100)/100 ;
			document.getElementById("preciototal").value=result2;
		}		



		</script>
	</head>
	<body onload=inicia2()>
		<div id="pagina">
			<div id="zonaContenido">
				<div align="center">
					<div id="botonBusqueda">					
						<div align="left">
							<img src="../img/botonaceptar.jpg" width="85" height="22" onClick="validar_cabecera()" border="1" onMouseOver="style.cursor=cursor">
							<img src="../img/botoncancelar.jpg" width="85" height="22" onClick="cancelar()" border="1" onMouseOver="style.cursor=cursor">					
						</div>
				      	</div>					
					
					<div id="tituloForm2" class="header">Liquidacion <?echo $titulo?></div>
					<div id="frmBusqueda2">					
						<form id="formulario" name="formulario" method="post" action="guardar_liquidacion.php">
							<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabCab" minimo=1 columnas=5 nrot=0>
							</tr>
							<? $hoy=date("d/m/Y"); ?>
							<tr>
								<td width="5%">&nbsp;</td>								
								<td width="20%">Fecha</td>
								<td width="32%"><input name="fecha" type="text" class="cajaPequena" id="fecha" size="10" maxlength="10" value="<? echo $hoy?>" > <img src="../img/calendario.png" name="ImageC" id="ImageC" width="16" height="16" border="0" onMouseOver="this.style.cursor='pointer'" onClick="elegirCalendario(this)"></td>	
								<td width="20%"><input type="checkbox" name="liq_check" id="liq_check" onclick="habilita_liq()"/>LIQUIDACION</td>
							    	<td width="20%"><input name="liq_nro" type="text" class="cajaMedia" id="liq_nro" size="20" maxlength="15" disabled="disabled" style="background-color:#72A4D2;"><font class="fuente8";><?echo " ".$tipoLiq?></font></td>					
							</tr>	
							<tr>
								<td width="5%">&nbsp;</td>
								<td width="20%">Plantilla</td>							
							    	<td width="32%"><?echo $des_plant?></td>															  
							</tr>												
							</table>								
							<input id="accion" name="accion" value="alta" type="hidden">
							<input id="tablasCont" name="tablasCont" type="hidden">
							<input id="liqTipo" name="liqTipo" type="hidden" value="<?echo $tipoLiq?>">
							<input id="cliente_liq" name="cliente_liq" type="hidden">													
							<input id="importe_total_liq" name="importe_total_liq" type="hidden">
							<input id="codigo_plantilla" name="codigo_plantilla" type="hidden" value="<?echo $codigo_plantilla?>">																																						
													
						</form><!--Fin de formulario1-->
					</div><!--Fin de frmBusqueda-->
					<br/>							
					<div id="tituloForm2" class="header">Datos</div>			
					<div id="frmBusqueda2">
						<form id="formulario_datos" name="formulario_datos" method="post" >
							<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabDatos" minimo=3 columnas=5 nrot=1>
								<?if($codigo_plantilla!=9999)
								{	$sel_lineas="SELECT fila_plantilla,columna_plantilla,valor_plantilla FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='1' ORDER BY fila_plantilla,columna_plantilla ASC";
									$rs_lineas=mysql_query($sel_lineas);
									$registro=array(); //registro con cada valor para celda
									$registro_tipo=array(); //registro con cada tipo dependiendo del valor
									$nrof=0; //nro de filas	
									$contfech=0; //contador de fechas							
									for ($i = 0; $i < mysql_num_rows($rs_lineas); $i++) { 
										$fila=mysql_result($rs_lineas,$i,"fila_plantilla");
										$columna=mysql_result($rs_lineas,$i,"columna_plantilla");
										$valor=mysql_result($rs_lineas,$i,"valor_plantilla");																								
						
										//Seleccionar el tipo de concepto de la tabla conceptos
										$sel="SELECT count(*) as c FROM conceptos WHERE descripcion like '$valor'";
										$rs=mysql_query($sel) or die(mysql_error());
										$c=mysql_result($rs,0,"c");
										if($c>0)
										{
											$sel="SELECT tipo FROM conceptos WHERE descripcion like '$valor'";
											$rs=mysql_query($sel) or die(mysql_error());
											$tipoc=mysql_result($rs,0,"tipo"); //tipo de concepto, alfanumerico o numerico											
										}
										//echo "valor: ".$valor." tipo: ".$tipoc."</br>";

										if($fila==$nrof)
										{											
											$registro[$columna-1]=$valor;
											$registro_tipo[$columna-1]=$tipoc;
										}
										else
										{	
											//echo $registro[0].":".$registro_tipo[0].",".$registro[2].":".$registro_tipo[2]."</br>";
											$i--;
										?>											
											<tr>												
												<?if ($nrof<2){?>
													<td width="5%">&nbsp;</td>	
													<td width="20%"><?echo $registro[0]?></td>
												<?}
												else{?>
													<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
													<td width="20%"><input type="text" class="cajaMedia" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>								
												<?}?>

												<?if($fila==1){?>
													<td witdh="32%"><input name="nombre" type="text" class="cajaCliente" id="nombre" maxlength="45" > <img id="img1" src="../img/ver.png" width="16" height="16" onClick="abreVentana(this)" title="Buscar cliente" onMouseOver="style.cursor=cursor"> <img src="../img/cliente.png" width="16" height="16" onClick="validarcliente()" title="Validar cliente" onMouseOver="style.cursor=cursor"></td>																	
												<?}else{
													if($fila==2){?>
														<td witdh="32%"><input name="ruc" type="text" class="cajaMedia" id="ruc" size="45" maxlength="45" readonly></td>																	
													<?}else{
														$regCelda=strtoupper($registro[0]);
														if($regCelda=='FECHA'){
															$contfech++;?>
															<td width="32%"><input name="fecha<?echo $contfech?>" type="text" class="cajaPequena" id="fecha<?echo $contfech?>" size="10" maxlength="10" value="<? echo $registro[1]?>" > <img src="../img/calendario.png" name="ImageC<?echo $contfech?>" id="ImageC<?echo $contfech?>" width="16" height="16" border="0" onMouseOver="this.style.cursor='pointer'" onClick="elegirCalendario(this)"></td>	
														<?}else{
															if($regCelda=='REGIMEN ADUANERO'){?>
																<td width="32%"><input type="text" class="cajaCliente" size="50" maxlength="50" value="<?echo $des_plant?>"></td>	
															<?}else{?>
																<td width="32%"><input type="text" class="cajaCliente" size="50" maxlength="50" > <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptosDato(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar datos conceptos"></td>
															<?}															
														}																									
													}
												}?>
												<td width="20%"><input type="text" class="cajaMedia" value="<?echo $registro[2]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>								
												<?$regCelda=strtoupper($registro[2]);
												if($regCelda=='FECHA'){
													$contfech++;?>
													<td width="20%"><input name="fecha<?echo $contfech?>" type="text" class="cajaPequena" id="fecha<?echo $contfech?>" size="10" maxlength="10" value="<? echo $hoy?>" > <img src="../img/calendario.png" name="ImageC<?echo $contfech?>" id="ImageC<?echo $contfech?>" width="16" height="16" border="0" onMouseOver="this.style.cursor='pointer'" onClick="elegirCalendario(this)"></td>
												<?}else{
													if($registro_tipo[2]=='A'){?>
														<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="20" style="text-align:right"></td>																					
													<?}else{
														$subCelda=strtoupper(substr($registro[2],0,15));
														if($subCelda=="VALOR IMPONIBLE"){?>
															<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="20" onfocus="calculaValorImponible(this)" readonly style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
														<?}else{?>
															<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="20" onkeyup="calculaDatos(this)" onfocus="calculaDatos(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
														<?}
													}//
												}?>

											</tr>																	
										<?
											$nrof++;								
											for($x=0;$x<4;$x++)													
												$registro[$x]="";	

										}
									}
									?>	
									<!--Para imprimir la ultima fila-->
									<tr>
										<?
										//echo $registro[0].":".$registro_tipo[0].",".$registro[2].":".$registro_tipo[2]."</br>";
										if ($nrof<2){?>
											<td width="5%">&nbsp;</td>	
											<td width="20%"><?echo $registro[0]?></td>
										<?}
										else{?>
											<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>															
											<td width="20%"><input type="text" class="cajaMedia" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>								
										<?}										
										$regCelda=strtoupper($registro[0]);
										if($regCelda=='FECHA'){
											$contfech++;?>
											<td width="32%"><input name="fecha<?echo $contfech?>" type="text" class="cajaPequena" id="fecha<?echo $contfech?>" size="10" maxlength="10" value="<? echo $registro[1]?>" > <img src="../img/calendario.png" name="ImageC<?echo $contfech?>" id="ImageC<?echo $contfech?>" width="16" height="16" border="0" onMouseOver="this.style.cursor='pointer'" onClick="elegirCalendario(this)"></td>	
										<?}else{
											if($regCelda=='REGIMEN ADUANERO'){?>
												<td width="32%"><input type="text" class="cajaCliente" size="50" maxlength="50" value="<?echo $des_plant?>"></td>	
											<?}else{?>
												<td width="32%"><input type="text" class="cajaCliente" size="50" maxlength="50"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptosDato(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar datos conceptos"></td>	
											<?}
										}?>
										<td width="20%"><input type="text" class="cajaMedia" value="<?echo $registro[2]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>								
										<?$regCelda=strtoupper($registro[2]);
										if($regCelda=='FECHA'){
										$contfech++;?>
											<td width="20%"><input name="fecha<?echo $contfech?>" type="text" class="cajaPequena" id="fecha<?echo $contfech?>" size="10" maxlength="10" value="<? echo $hoy?>" > <img src="../img/calendario.png" name="ImageC<?echo $contfech?>" id="ImageC<?echo $contfech?>" width="16" height="16" border="0" onMouseOver="this.style.cursor='pointer'" onClick="elegirCalendario(this)"></td>	
										<?}else{
											if($registro_tipo[2]=='A'){?>
												<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="20" style="text-align:right"></td>																					
											<?}else{
												$subCelda=strtoupper(substr($registro[2],0,15));
												if($subCelda=="VALOR IMPONIBLE"){?>
													<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="20" onfocus="calculaValorImponible(this)" readonly style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
												<?}else{?>
													<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="20" onkeyup="calculaDatos(this)" onfocus="calculaDatos(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>								
												<?}
											}
										}?>							
									</tr>	
									<!--En el caso que tenga solo Cliente y RUC como filas-->
									<?if($nrof==1){?>
									<tr>
										<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>															
										<td width="20%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>								
										<td witdh="32%"><input name="nombre" type="text" class="cajaCliente" id="nombre" size="45" maxlength="45" ></td>																										
										<td width="20%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>								
										<td width="20%"><input type="text" class="cajaMedia" size="20" maxlength="15" onkeyup="calculaDatos(this)" onfocus="calculaDatos(this)"></td>								
									</tr>
									<?}
							}
							else
							{?>								
								<tr>
									<td width="5%">&nbsp;</td>	
									<td width="20%">Cliente</td>
									<td witdh="32%"><input name="nombre" type="text" class="cajaCliente" id="nombre" size="45" maxlength="45" >								
									<img id="img1" src="../img/ver.png" width="16" height="16" onClick="abreVentana(this)" title="Buscar cliente" onMouseOver="style.cursor=cursor"> <img src="../img/cliente.png" width="16" height="16" onClick="validarcliente()" title="Validar cliente" onMouseOver="style.cursor=cursor"></td>					
									<td width="20%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
									<td width="20%"><input name="despimpnro" type="text" class="cajaMedia" id="nif" size="20" maxlength="15" ></td>
								</tr>							
								<tr>
									<td width="5%">&nbsp;</td>	
									<td width="20%">RUC</td>
									<td width="32%"><input name="ruc" type="text" class="cajaCliente" id="ruc" size="45" maxlength="45" readonly>								
									<td witdh="20%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
									<td width="20"><input type="text" class="cajaMedia" size="10" maxlength="10" align="right"></td>
								</tr>	
								<tr>
									<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor">
										       <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor">		
									</td>							
								
									<td witdh="20%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
									<td width="32%" align="left"><input name="valor1" type="text" id="valor1" class="cajaCliente" size="20" maxlength="20" onkeyup="calculaDatos(this)" onfocus="calculaDatos(this)"></td>
									<td witdh="20%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
									<td width="20"><input type="text" class="cajaMedia" size="10" maxlength="10" align="right" style="text-align:right"></td>
								</tr>																					
							<?}?>															
							</table>	
							<input type="hidden" id="codcliente" name="codcliente">
					</div>					
					</form><!--Fin de formulario_datos-->
				<br/>	
				<div id="frmBusqueda2">
					<form id="formulario_lineas1" name="formulario_lineas1" method="post" action="frame_lineas.php" target="frame_lineas">					
						<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabObsDatos" minimo=1 columnas=1 nrot=2>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%">Observaciones</td>
							</tr>
							<tr>
								<td width="1%">&nbsp;</td>

								<td width="99%"><textarea name="descDatos" id="descDatos" class="areatexto" rows="4" cols="130" wrap="virtual">Detallamos los costos para la Liquidacion conforme documentos adjuntos</textarea></td>		
							</tr>

						</table>	
					</form><!--Fin de formulario_lineas-->
				</div>
				<br/>
				<div align="center">
				<div id="tituloForm2" class="header">Aduana</div>
				<div id="frmBusqueda3">
				<form id="formulario_lineas" name="formulario_lineas" method="post" action="frame_lineas2.php" style="table-layout:fixed">
					<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabAduana" minimo=3 columnas=4 nrot=3>
						<col width="4%">
						<col width="50%">
						<?$sel2="SELECT count(codigo_plantilla) as col FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='2' AND fila_plantilla='1'";
						$rs2=mysql_query($sel2) or die(mysql_error());
						$col=mysql_result($rs2,0,"col");
						if($col>0){?>
							<tr class="cabeceraTabla">
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<?for($cc=0;$cc < $col-1;$cc++){?>
								      <td>&nbsp;<img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar columna" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar columna" onMouseOver="style.cursor=cursor"></td>
								      <!--<td>&nbsp;</td>-->
								<?}?>
							</tr>
						<?}else{?>
							<tr class="cabeceraTabla">
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>

							<tr class="cabeceraTabla">
								<td>&nbsp;</td>
								<td>DESCRIPCION</td>
								<td>Liberado</td>
								<td>Tributado</td>
							</tr>
						<?}
						if($codigo_plantilla!=9999)
						{?>
							<!--<tr class="cabeceraTabla">
								<td width="5%">&nbsp;</td>
								<td width="55%">DESCRIPCION</td>
								<td width="20%">LIBERADO</td>
								<td width="20%">TRIBUTADO</td>
							</tr>-->
						<?	$sel_lineas="SELECT fila_plantilla,columna_plantilla,valor_plantilla FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='2' ORDER BY fila_plantilla,columna_plantilla ASC";
							$rs_lineas=mysql_query($sel_lineas);
							$registro=array();
							$nrof=1; //nro de filas
							for ($i = 0; $i < mysql_num_rows($rs_lineas); $i++) { 
								$fila=mysql_result($rs_lineas,$i,"fila_plantilla");
								$columna=mysql_result($rs_lineas,$i,"columna_plantilla");
								$valor=mysql_result($rs_lineas,$i,"valor_plantilla");
					
								if($fila==$nrof)
								{
									$registro[$columna-1]=$valor;

// 											if($fila==1) // es para los titulos
// 												$registro[$columna-1]="<b>".$valor."</b>";
// 											else
// 											{	$registro[$columna-1]=$valor;
// 												for($cc=0;$cc < $col-1;$cc++)
// 													$registro[$columna+$cc]='<input type="text" class="cajaPequena" readonly>';
// 											}
								}
								else
								{	
									$i--;
									if($nrof==1){?>
										<tr class="cabeceraTabla">
										      <td>&nbsp;</td>
										      <?for($cc=0;$cc < $col;$cc++){
											    if($cc==0){?>
												  <td><?echo $registro[$cc]?></td>
											    <?}else{?>
												  <td><?echo $registro[$cc]?></td>
											    <?}
										      }?>
										</tr>
									<?}else{?>
										<tr>
											<td><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
											<td><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
											<?for($cc=0;$cc < $col-1;$cc++){?>
											      <td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
											<?}?>
										</tr>

									<?}
									$nrof++;
									for($x=0;$x<4;$x++)
										$registro[$x]="";

								}
							}
							//Para imprimir la ultima fila
							if($col>0){?>
							      <tr>
								      <td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
								      <td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
								      <?for($cc=0;$cc < $col-1;$cc++){?>
									    <td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
								      <?}?>
							      </tr>
							<?}else{?>
							      <tr>
								      <td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
								      <td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
								      <td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
								      <td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
							      </tr>
							<?}
						}
						else
						{?>
						<!--<tr class="cabeceraTabla">
							<td width="5%">&nbsp;</td>
							<td width="55%">DESCRIPCION</td>
							<td width="20%">LIBERADO</td>
							<td width="20%">TRIBUTADO</td>
						</tr>-->
						<tr>
							<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor">
								       <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor">		
							</td>															
							<td witdh="55%"><input name="descripcion" type="text" id="descripcion" class="cajaGrande2"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
							<td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="miles(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
							<td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
						</tr>
						<?}?>
					</table>	
				</form><!--Fin de formulario2-->
				</div>
				<br/>
				<div id="frmBusqueda2">
					<form id="formulario_lineas2" name="formulario_lineas2" method="post">					
						<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabObsAduana" minimo=1 columnas=1 nrot=4>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%">Observaciones</td>								
							</tr>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%"><textarea name="descAduana" id="descAduana" class="areatexto" rows="4" cols="130" wrap="virtual"></textarea></td>		
							</tr>
						</table>	
					</form><!--Fin de formulario_lineas2-->
				</div>				
				</br>
				<div id="tituloForm2" class="header">Otros Gastos</div>						  
				<div id="frmBusqueda3">
					<form id="formulario_lineas4" name="formulario_lineas4" method="post">				
						<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabOtros" minimo=3 columnas=4 nrot=7>							
							<?$sel2="SELECT count(codigo_plantilla) as col FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='4' AND fila_plantilla='1'";
							$rs2=mysql_query($sel2) or die(mysql_error());
							$col=mysql_result($rs2,0,"col");
							//echo "Tamaño: ".$col;

							if($col>0){?>
								<tr class="cabeceraTabla">
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<?for($cc=0;$cc < $col-1;$cc++){?>
									      <td>&nbsp;<img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar columna" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar columna" onMouseOver="style.cursor=cursor"></td>
									<?}?>
								</tr>
							<?}else{?>
								<tr class="cabeceraTabla">
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
								</tr>

								<tr class="cabeceraTabla">
									<td width="4%">&nbsp;</td>
									<td width="40%">DESCRIPCION</td>
									<td width="12%">&nbsp;</td>
									<td width="12%">IMPORTE</td>
								</tr>
							<?}
							if($codigo_plantilla!=9999)
							{
								$sel_lineas="SELECT fila_plantilla,columna_plantilla,valor_plantilla FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='4' ORDER BY fila_plantilla,columna_plantilla ASC";
								$rs_lineas=mysql_query($sel_lineas);
								$registro=array();
								$nrof=1; //nro de filas
								for ($i = 0; $i < mysql_num_rows($rs_lineas); $i++) { 
									$fila=mysql_result($rs_lineas,$i,"fila_plantilla");
									$columna=mysql_result($rs_lineas,$i,"columna_plantilla");
									$valor=mysql_result($rs_lineas,$i,"valor_plantilla");
						
									if($fila==$nrof)
									{
										$registro[$columna-1]=$valor;
									}
									else
									{
										$i--;

										if($nrof==1){
										?>
											<tr class="cabeceraTabla">
											      <td>&nbsp;</td>
											      <?for($cc=0;$cc < $col;$cc++){
												    if($cc==0){?>
													  <td><?echo $registro[$cc]?></td>
												    <?}else{?>
													  <td><?echo $registro[$cc]?></td>
												    <?}
											      }?>
											</tr>
										<?}else{?>
											<tr>
												<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
												<td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
												<?for($cc=0;$cc < $col-1;$cc++){?>
												      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
												<?}?>
											</tr>
										<?}
										$nrof++;
										for($x=0;$x<4;$x++)
											$registro[$x]="";
									}
								}										
								//Para imprimir la ultima fila-
								if($col>0){?>
								      <tr>
									      <td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
									      <td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
									      <?for($cc=0;$cc < $col-1;$cc++){?>
										    <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
									      <?}?>
								      </tr>
								<?}else{?>
								      <tr>
									      <td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
									      <td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
									      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
									      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>





								      </tr>
								<?}
							}
							else
							{?>
								<!--<tr class="cabeceraTabla">
									<td width="5%">&nbsp;</td>
									<td width="55%">DESCRIPCION</td>
									<td width="20%">&nbsp;</td>
									<td width="20%">IMPORTE</td>
								
								</tr>-->
								<tr>						
									<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor">
										       <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor">		
									</td>							
								
									<td witdh="55%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
									<td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="miles(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>								
									<td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
								</tr>
							<?}?>
						</table>
				</div><!--Fin frmBusqueda2--> 
				<br/>
				<div id="frmBusqueda2">
					<form id="formulario_lineas1" name="formulario_lineas1" method="post" action="frame_lineas.php" target="frame_lineas">					
						<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabObsOtros" minimo=1 columnas=1 nrot=8>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%">Observaciones</td>								
							</tr>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%"><textarea name="descOtros" id="descOtros" class="areatexto" rows="4" cols="130" wrap="virtual"></textarea></td>		
							</tr>
						</table>	
					</form><!--Fin de formulario_lineas-->
				</div>				
				<br/>
				<div align="center">
				<div id="tituloForm2" class="header">Despachante</div>						  
				<div id="frmBusqueda3">
					<form id="formulario_lineas3" name="formulario_lineas3" method="post">					
					<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabDespacho" minimo=3 columnas=4 nrot=5>
						<?$sel2="SELECT count(codigo_plantilla) as col FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='3' AND fila_plantilla='1'";
						$rs2=mysql_query($sel2) or die(mysql_error());
						$col=mysql_result($rs2,0,"col");
						//echo "Tamaño: ".$col;
						if($col>0){?>
							<tr class="cabeceraTabla">
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<?for($cc=0;$cc < $col-1;$cc++){?>
								      <td>&nbsp;<img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar columna" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar columna" onMouseOver="style.cursor=cursor"></td>
								<?}?>
							</tr>
						<?}else{?>
							<tr class="cabeceraTabla">
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
							</tr>

							<tr class="cabeceraTabla">
								<td width="4%">&nbsp;</td>
								<td width="40%">DESCRIPCION</td>
								<td width="12%">&nbsp;</td>
								<td width="12%">IMPORTE</td>
							</tr>
						<?}
						if($codigo_plantilla!=9999)
						{
							$sel_lineas="SELECT fila_plantilla,columna_plantilla,valor_plantilla FROM plantillaDetalles WHERE codigo_plantilla='$codigo_plantilla' AND cod_tabla_plantilla='3' ORDER BY fila_plantilla,columna_plantilla ASC";
							$rs_lineas=mysql_query($sel_lineas);
							$registro=array();
							$nrof=1; //nro de filas
							for ($i = 0; $i < mysql_num_rows($rs_lineas); $i++) { 
								$fila=mysql_result($rs_lineas,$i,"fila_plantilla");
								$columna=mysql_result($rs_lineas,$i,"columna_plantilla");
								$valor=mysql_result($rs_lineas,$i,"valor_plantilla");

								if($fila==$nrof)
								{
									$registro[$columna-1]=$valor;
								}
								else
								{	
									$i--;
									if($nrof==1){?>
										<tr class="cabeceraTabla">
										      <td>&nbsp;</td>
										      <?for($cc=0;$cc < $col;$cc++){
											    if($cc==0){?>
												  <td><?echo $registro[$cc]?></td>
											    <?}else{?>
												  <td><?echo $registro[$cc]?></td>
											    <?}
										      }?>
										</tr>
									<?}else{?>
										<tr>
											<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>														
											<td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
											<?$sw_hon=0;
											for($cc=0;$cc < $col-1;$cc++){
												$subCelda=strtoupper(substr($registro[0],0,3));
												if($subCelda=="HON"){
													if($sw_hon==0){
														$sw_hon=1;?>
													      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaHonorario(this)" onfocus="calculaHonorario(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
													<?}else{?>
													      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
													<?}											
												}else{?>																																	
												      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
												<?}
											}?>
										</tr>
									<?}
									$nrof++;
									for($x=0;$x<4;$x++)
										$registro[$x]="";

								}
							}
							//Para imprimir la ultima fila

							if($col>0){?>
							      <tr>
								      <td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
								      <td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
								      <?for($cc=0;$cc < $col-1;$cc++){?>
									    <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
								      <?}?>
							      </tr>
							<?}else{?>
							      <tr>
								      <td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor"> <img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor"></td>
								      <td witdh="50%"><input NAME="descripcion" type="text" id="descripcion" class="cajaGrande2" value="<?echo $registro[0]?>"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar articulos"></td>
								      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
								      <td width="20%" align="left"><input type="text" class="cajaMedia" size="16" maxlength="16" onkeyup="calculaTotal(this)" onfocus="calculaTotal(this)" style="text-align:right"> <img src="../img/calculadora2.png" width="16" height="16" onMouseOver="style.cursor=cursor" title="Calcular" onclick="calculadora(this.parentNode)"></td>
							      </tr>
							<?}
						}
						else
						{?>
							<!--<tr class="cabeceraTabla">
								<td width="5%">&nbsp;</td>
								<td width="55%">DESCRIPCION</td>
								<td width="20%">&nbsp;</td>
								<td width="20%">IMPORTE</td>
							
							</tr>-->
							<tr>
								<td width="5%"><img src="../img/agregar.png" width="16" height="16" title="Agregar datos" alt="agregar fila" onMouseOver="style.cursor=cursor">
										<img src="../img/remover.png" width="16" height="16" title="Quitar datos" alt="borrar fila" onMouseOver="style.cursor=cursor">
								</td>
							
								<td witdh="55%"><input type="text" class="cajaMedia"> <img src="../img/ver.png" width="16" height="16" onClick="ventanaConceptos(this.parentNode)" onMouseOver="style.cursor=cursor" title="Buscar conceptos"></td>
								<td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onkeyup="calculaHonorario(this)" onfocus="calculaHonorario(this)" style="text-align:right"></td>								
								<td width="20%" align="left"><input type="text" class="cajaMedia" size="15" maxlength="15" onfocus="calculaTotal(this)" readonly style="text-align:right"> </td>
							</tr>
						<?}?>
					</table>
					</div>
					<input name="codarticulo" value="<? echo $codarticulo?>" type="hidden" id="codarticulo">
				</div>
				</br>
				<div id="frmBusqueda2">
					<form id="formulario_lineas1" name="formulario_lineas1" method="post" action="frame_lineas.php" target="frame_lineas">					
						<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabObsDespachos" minimo=1 columnas=1 nrot=6>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%">Observaciones</td>								
							</tr>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="99%"><textarea name="descDesp" id="descDesp" class="areatexto" rows="4" cols="130" wrap="virtual"></textarea></td>
							</tr>
						</table>	
					</form><!--Fin de formulario_lineas-->
				</div>
				<br/>
				<div id="frmBusqueda2">
					<form id="formulario_total" name="formulario_total">
						<table class="fuente8" width="98%" cellspacing=0 cellpadding=3 border=0 id="tabTotal" minimo=1 columnas=3 nrot=9>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="79%"><b>TOTAL LIQUIDACION</b></td>
								<td width="20%"><input name="total" type="text" class="cajaMedia" id="total" size="30" maxlength="30" readonly style="text-align:right"></td>
							</tr>
							<tr>
								<td width="1%"><input type="checkbox" name="check_adelanto" id="check_adelanto" onclick="habilita_saldo()"/></td>
								<td width="79%"><b>TOTAL ADELANTO</b></td>
								<td width="20%"><input name="adelanto" type="text" class="cajaMedia" id="adelanto" size="17" maxlength="17" onkeyup="calculaSaldo(this)" disabled="disabled" style="background-color:#72A4D2;text-align:right"></td>
							</tr>
							<tr>
								<td width="1%">&nbsp;</td>
								<td width="79%"><b>TOTAL SALDO</b></td>
								<td width="20%"><input name="saldo" type="text" class="cajaMedia" id="saldo" size="30" maxlength="30" disabled="disabled" style="background-color:#72A4D2;text-align:right" readonly></td>
							</tr>
						</table>	
					</form><!--Fin de formulario_lineas-->
				</div>
				<div id="botonBusqueda">					
					<div align="center">					    
						<input id="codfamilia" name="codfamilia" value="<? echo $codfamilia?>" type="hidden">
						<input id="codfacturatmp" name="codfacturatmp" value="<? echo $codfacturatmp?>" type="hidden">	
						<input id="preciototal2" name="preciototal" value="<? echo $preciototal?>" type="hidden">			    
					</div>
				</div>
				  </form><!--Fin de formulario3-->
				 </div><!--Fin de frmBusqueda-->
			  </div><!--Fin de zonaContenido-->
		</div><!--Fin de pagina-->
	</body>
</html>
